package com.dl7.playerdemo.slice;

import com.dl7.playerdemo.*;
import ohos.aafwk.ability.AbilitySlice;
import ohos.aafwk.content.Intent;
import ohos.aafwk.content.Operation;
import ohos.agp.components.Component;
import ohos.agp.window.dialog.ToastDialog;

public class MainAbilitySlice extends AbilitySlice {
    @Override
    public void onStart(Intent intent) {
        super.onStart(intent);
        super.setUIContent(ResourceTable.Layout_ability_main);
        findComponentById(ResourceTable.Id_btn_video)
                .setClickedListener(new Component.ClickedListener() {
            @Override
            public void onClick(Component component) {
                Intent intentIjkPlayer = new Intent();
                Operation operation = new Intent.OperationBuilder()
                        .withDeviceId("")
                        .withBundleName(getBundleName())
                        .withAbilityName(IjkPlayerActivity.class.getName())
                        .build();
                intentIjkPlayer.setOperation(operation);
                startAbility(intentIjkPlayer);

                new ToastDialog(getContext()).setText("IjkPlayerActivity").show();

            }
        });
        findComponentById(ResourceTable.Id_btn_fullscreen_video)
                .setClickedListener(new Component.ClickedListener() {
            @Override
            public void onClick(Component component) {
                Intent intentIjkFullscreen = new Intent();
                Operation operation = new Intent.OperationBuilder()
                        .withDeviceId("")
                        .withBundleName(getBundleName())
                        .withAbilityName(IjkFullscreenActivity.class.getName())
                        .build();
                intentIjkFullscreen.setOperation(operation);
                startAbility(intentIjkFullscreen);
                new ToastDialog(getContext()).setText("IjkFullscreenActivity").show();
            }
        });
        findComponentById(ResourceTable.Id_btn_test_aspect)
                .setClickedListener(new Component.ClickedListener() {
            @Override
            public void onClick(Component component) {
                Intent intentTestAspectA = new Intent();
                Operation operation = new Intent.OperationBuilder()
                        .withDeviceId("")
                        .withBundleName(getBundleName())
                        .withAbilityName(TestAspectActivity.class.getName())
                        .build();
                intentTestAspectA.setOperation(operation);
                startAbility(intentTestAspectA);
            }
        });
        findComponentById(ResourceTable.Id_btn_custom_danmaku)
                .setClickedListener(new Component.ClickedListener() {
            @Override
            public void onClick(Component component) {
                Intent intentCustomDanmaku = new Intent();
                Operation operation = new Intent.OperationBuilder()
                        .withDeviceId("")
                        .withBundleName(getBundleName())
                        .withAbilityName(CustomDanmakuActivity.class.getName())
                        .build();
                intentCustomDanmaku.setOperation(operation);
                startAbility(intentCustomDanmaku);
            }
        });
        findComponentById(ResourceTable.Id_btn_switch_video)
                .setClickedListener(new Component.ClickedListener() {
            @Override
            public void onClick(Component component) {
                Intent intentSwitchVideo = new Intent();
                Operation operation = new Intent.OperationBuilder()
                        .withDeviceId("")
                        .withBundleName(getBundleName())
                        .withAbilityName(SwitchVideoActivity.class.getName())
                        .build();
                intentSwitchVideo.setOperation(operation);
                startAbility(intentSwitchVideo);
            }
        });
    }

    @Override
    public void onActive() {
        super.onActive();
    }

    @Override
    public void onForeground(Intent intent) {
        super.onForeground(intent);
    }
}
